<template>
  <div v-if="Object.keys(goods).length !== 0" class="base-info">
    <div class="info-title">{{goods.title}}</div>
    <div class="info-price">
      <span class="n-price">{{goods.newPrice}}</span>
      <span class="o-price">{{goods.oldPrice}}</span>
      <span v-if="goods.discount" class="discount">{{goods.discount}}</span>
    </div>
    <div class="info-other">
      <span>{{goods.columns[0]}}</span>
      <span>{{goods.columns[1]}}</span>
      <span>{{goods.services[goods.services.length-1].name}}</span>
    </div>
    <div class="info-service">
      <span class="info-service-item" v-for="index in goods.services.length-1" :key=index>
        <img :src="goods.services[index-1].icon">
        <span>{{goods.services[index-1].name}}</span>
      </span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "DetailBaseInfo",
    props: {
      goods: {
        type: Object,
        default() {
          return {}
        }
      }
    }
  }
</script>

<style scoped>
  .base-info {
    margin-top: 15px;
    padding: 0 8px;
    color: #999;
    border-bottom: 5px solid #f2f5f8;
  }

  .info-title {
    color: #222;
  }

  .info-price {
    margin-top: 10px;
  }

  .info-price .n-price {
    font-size: 24px;
    color: var(--color-high-text);
  }

  .info-price .o-price {
    font-size: 13px;
    margin-left: 5px;
    text-decoration: line-through;
  }

  .discount {
    font-size: 13px;
    background-color: var(--color-high-text);
    color: white;
    padding: 3px;
    border-radius: 20px;
    margin-left: 5px;
    position: absolute;
  }

  .info-other {
    position: relative;
    margin-top: 25px;
    padding-bottom: 8px;
    text-align: center;
    border-bottom: solid #eee;
  }

  .info-other span:first-child {
    position: absolute;
    left: 0;
  }
  .info-other span:last-child {
    position: absolute;
    right: 0;
  }

  .info-service {
    position: relative;
    font-size: 15px;
    color: rgba(23, 23, 23, 0.93);
    padding: 25px 0 25px 0;
    display: flex;
  }

  .info-service-item {
    flex: 1;
  }

  .info-service-item img  {
    height: 15px;
    width: 15px;
  }


</style>
